package com.kelvin.paopao.widgets.dialog;

import android.app.Activity;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

import com.kelvin.kelvinlib.utils.LogUtil;
import com.kelvin.paopao.R;
import com.kelvin.paopao.module.main.date.publish.eat.PublicEatActivity;
import com.kelvin.paopao.module.main.date.publish.movie.PublishMovieActivity;
import com.kelvin.paopao.module.main.date.publish.other.PublishOtherActivity;
import com.kelvin.paopao.module.main.date.publish.sing.PublishSingActivity;
import com.kelvin.paopao.module.main.date.publish.sport.PublishSportActivity;
import com.kelvin.paopao.module.main.date.publish.travel.PublishTravelActivity;
import com.kelvin.paopao.utils.AnimateHelper;

import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * 发布邀约的对话框
 * Created by kelvin on 2016/12/13.
 */

public class PublishDateFragment extends DialogFragment {

    private Activity activity;
    private FloatingActionButton fab;

    @Override
    public void onAttach(Activity activity) {

        super.onAttach(activity);
        this.activity = activity;
    }

    public static PublishDateFragment newInstance() {
        PublishDateFragment f = new PublishDateFragment();

        Bundle args = new Bundle();
        f.setArguments(args);

        return f;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getDialog().getWindow().setWindowAnimations(R.style.animate_dialog);

        View view = inflater.inflate(R.layout.dialog_publish_date, container);
        ButterKnife.bind(this, view);



        return view;
    }


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @OnClick({R.id.ll_publish_eat, R.id.ll_publish_movie, R.id.ll_publish_sport, R.id.ll_publish_travel, R.id.ll_publish_sing, R.id.ll_publish_other})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ll_publish_eat:
                PublicEatActivity.launch(getContext());
                dismiss();
                break;
            case R.id.ll_publish_movie:
                PublishMovieActivity.launch(getContext());
                dismiss();
                break;
            case R.id.ll_publish_sport:
                PublishSportActivity.launch(getContext());
                dismiss();
                break;
            case R.id.ll_publish_travel:
                PublishTravelActivity.launch(getContext());
                dismiss();
                break;
            case R.id.ll_publish_sing:
                PublishSingActivity.launch(getContext());
                dismiss();
                break;
            case R.id.ll_publish_other:
                PublishOtherActivity.launch(getContext());
                dismiss();
                break;
        }
    }


    @Override
    public void onDismiss(DialogInterface dialog) {
        super.onDismiss(dialog);
        Fragment parentFragment = getParentFragment();
        if (parentFragment instanceof DialogInterface.OnDismissListener) {
            ((DialogInterface.OnDismissListener) parentFragment).onDismiss(dialog);
        }
    }
}
